CREATE TABLE [dbo].[TXMODE_DIST]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TXMODE_DI__NU_AN__414EAC47] DEFAULT (datepart(year,getdate())),
[CO_MODE_DIST] [dbo].[TD_VC_003] NOT NULL,
[NU_SECU] [dbo].[TD_IN_001] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[NO_MODE_DIST] [dbo].[TD_VC_050] NOT NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[TI_OPER] [dbo].[TD_VC_003] NOT NULL CONSTRAINT [DF__TXMODE_DI__TI_OP__442B18F2] DEFAULT ('CAR'),
[CO_ORDE_SERV] [dbo].[TD_VC_020] NULL,
[PC_DIST] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TXMODE_DI__PC_DI__46136164] DEFAULT ((1.000)),
[ST_CNTA_PRIN] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TXMODE_DI__ST_CN__47FBA9D6] DEFAULT ('N'),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TXMODE_DI__FE_US__49E3F248] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TXMODE_DI__FE_US__4AD81681] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [CK__TXMODE_DI__CO_CN__4336F4B9] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [CK__TXMODE_DI__NU_AN__4242D080] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [CK__TXMODE_DI__PC_DI__4707859D] CHECK (([PC_DIST]>=(0)))
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [CK__TXMODE_DI__ST_CN__48EFCE0F] CHECK (([ST_CNTA_PRIN]='N' OR [ST_CNTA_PRIN]='S'))
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [CK__TXMODE_DI__TI_OP__451F3D2B] CHECK (([TI_OPER]='ABO' OR [TI_OPER]='CAR'))
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [XPKTXMODE_DIST] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [CO_MODE_DIST], [NU_SECU]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [FK1_TMPARA_CONT_A_TXMODE_DIST] FOREIGN KEY ([CO_EMPR]) REFERENCES [dbo].[TMPARA_CONT] ([CO_EMPR])
GO
ALTER TABLE [dbo].[TXMODE_DIST] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TXMODE_DIST] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
